<template>
  <div class="innerPageTable-out-flex">
    <!-- <SelfAdaption>
      <div class="btn-box" slot="adaption-bar">
        <Button type="primary" @click="createNamespace" style="margin-right: 10px">新建</Button>
        <Button @click="searchInfo">刷新</Button>
      </div>
    </SelfAdaption> -->
    <InnerPageTable ref="tableRef" :config="pageTableConfig">
      <div slot="table-bar">
        <Button type="primary" @click="createNamespace" style="margin-right: 10px">新建</Button>
        <Button @click="searchInfo">刷新</Button>
      </div>
    </InnerPageTable>
  </div>
</template>

<script>
import API from "@/api/nacosNamespace";
import deleteModel from "./deleteModel.vue";
import createModel from "./createModel.vue";
import { generateColumns } from "./colomns";
export default {
  name: "nacosNamespaceIndex",
  components: {},
  props: {},
  data() {
    return {
      pageTableConfig: {
        resource: [],
        columns: generateColumns.bind(this)(),
        autoFirst: true,
        isPage: false
      }
    };
  },
  created() {},
  mounted() {
    this.getListPage();
  },
  methods: {
    createNamespace() {
      new this.$pageModal(
        createModel,
        {
          props: {}
        },
        data => {
          if (data) {
            this.getListPage();
          }
        }
      );
    },
    deleteHandle(row) {
      new this.$pageModal(
        deleteModel,
        {
          props: {
            row
          }
        },
        data => {
          if (data) {
            this.getListPage();
          }
        }
      );
    },
    getListPage() {
      API.getListPage({}).then(data => {
        this.$nextTick(() => {
          this.$refs["tableRef"].resource = (data && data.data) || [];
          this.$refs["tableRef"].loadLocal();
        });
      });
    },
    // 搜索查询
    searchInfo() {
      this.getListPage();
    }
  },
  computed: {},
  watch: {}
};
</script>

<style lang='less' scoped >
.btn-box {
  display: flex;
  justify-content: flex-end;
}
</style>
